module.exports = function ($scope, $state, $resource, $modal, toaster, $stateParams ){
    
    $scope.search = function (pageNo){
        var para = {
            'pageNo': pageNo || $scope.currentPage,
            'pageSize': $scope.itemsPerPage,
            'change_type': $stateParams.change_type
            
        }
        $resource('/api/ac/goc/counselingService/findMyLogList', {}, {}).save(para, function(res){
            if(res.errcode === 0){
                $scope.list = res.data.results;
                $scope.totalItems = res.data.totalRecord;

                $scope.currentPage = pageNo;
            }else{
                toaster.error({title: '', body: res.errmsg});
            }
        });
    }

    //查询type列表
    $scope.searchtype = function (){
        var para = {
            'type': '4',
            'state': '1'
        }
        $resource('/api/as/goc/pelawinfo/findTypeList', {}, {}).save(para, function(res){
            if(res.errcode === 0){
                $scope.typelist = res.data.results;
            }else{
                toaster.error({title: '', body: res.errmsg});
            }
        });
    }
   


    init();
    //初始化列表
    function init(){
        $scope.currentPage = 1;		//当前页码
        $scope.itemsPerPage = 10;	//每页显示几条
        $scope.searchform = {};
        $scope.search(1);
        $scope.searchtype();
    }

     
    //查看
    $scope.gatRulesInfo = function(info) {
        info.openstate = true;
        if( $stateParams.state == '0'){
            info.audit = true;
        }
        var modalInstance = $modal.open({
            template: require('../views/saveWarehouseInfo.html'),
            controller: 'saveWarehouseInfo',
            size: 'lg',
            resolve: {
                item : function () {
                    return info;
                },
                flag : function () {
                    return info == 1;
                },
                change_type : function () {
                    return '3';//0管理员直接修改题库   1客服申请修改题库    2修改我的笔记 3 查看
                }
            }
        });
        //关闭模态框刷新页面
        modalInstance.result.then(function() {
            info.openstate = 'false';
            init();
        });
    }

 


};